home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / flilib.zip / FLISRC.ZIP / CHANGEDI.C < prev    next >
C/C++ Source or Header  |  1989-11-16  |  878b  |  43 lines

  1.  
  2. #include "aai86.h"
  3. #include "aados.h"
  4. #include <ctype.h>
  5.  
  6. /* Hey dos - I want to go to this directory.  Actually this changes
  7.    both device and directory at once.  eg name could be
  8.            C:\VPAINT\FISHIES  */
  9. Boolean dos_change_dir(char *name)
  10. {
  11. union i86_regs r;
  12. int d,od;
  13.  
  14. od = dos_get_dev ();
  15. if (!name[0])
  16.     return(1);
  17. if (name[1] == ':')    /* got a device... */
  18.     {
  19.     d = name[0];
  20.     if (islower(d))
  21.         d = _toupper(d);
  22.     d -= 'A';
  23.     if (!dos_valid_device(d))
  24.         return(0);
  25.     if (!dos_change_dev(d))
  26.         return(0);
  27.     name += 2;
  28.     }
  29. if (!name[0])
  30.     return(1);
  31. r.b.ah = 0x3B;    /* change current directory function */
  32. r.w.dx = i86_ptr_offset(name);
  33. r.w.ds = i86_ptr_seg(name);
  34. if (i86_sysint(0x21,&r,&r)&1)    /* check carry flag for error... */
  35.     {
  36.     dos_change_dev(od);    /* change to old device if directory doesn't exist */
  37.     return(0);
  38.     }
  39. return(1);
  40. }
  41.  
  42.  
  43.